<template>
  <view class="customerBox" @click="jumpDetail">
    <view class="name">
    <span>{{ data.name }}</span>
    <span>{{ lineName(data.lineName) }}</span>
    <span v-if="data.isCurDay===1">当天</span>
    </view>
    <view class="address">{{ data.address }}</view>
    <view class="distance">{{ setDistance(data.distance) }}</view>
    <view class="now" v-if="data.visited === 1">拜访中</view>
  </view>
</template>

<script>
export default {
  name: "customerVisit",
  props:{
    data:{
      type: Object,
      default: {}
    },
    // visitor:{
    //   type:Number,
    //   default:0
    // }
  },
  computed:{
  },
  data(){
    return {
    }
  },
  methods:{
    lineName(e){
      const tmp = e
      if (!tmp && typeof(tmp)!="undefined" && tmp!=0) {
        return ''
      }else{
        return e
      }
    },
    jumpDetail(e){
      if (this.visitor==1) {
      const app = getApp()
      app.globalData.customer = Object.assign({},this.data)
      uni.navigateTo({url:`/order/visitor/index?customdeId=${this.data.id}`})
      return
      }else{
        const app = getApp()
        app.globalData.customer = Object.assign({},this.data)
        uni.navigateTo({url:`/pageDelivery/home/detail?customdeId=${this.data.id}`})
      }
    },
    setDistance(dis){
      if (dis < 1000){
        if (dis === null)return '未设置客户位置'
        return ~~dis + 'm'
      }else {
        return (dis/1000).toFixed(2) + 'km'
      }
    }
  },

}
</script>

<style lang="scss" scoped>
.customerBox{
  .name{
    font-size: 32rpx;
    padding: 20rpx 0;
    font-family: PingFangSC Medium;
    font-weight: 400;
    font-weight: Medium;
    width: 97%;
    display: flex;
    span{
      width: 33%;
      margin-right:20rpx;
    }
  }
  .address{
    font-size: 27rpx;
    color: #858585;
  }
  .distance{
    font-family: PingFangSC Medium;
    position: absolute;
    right: 0;
    top: 20rpx;
    color:#31B4FB;
    font-size: 32rpx;
  }
  .now{
    color: #F84213;
    font-size: 32rpx;
    position: absolute;
    right: 30rpx;
    top: 60rpx;
    font-weight: bold;
  }
  position: relative;
  padding-bottom: 20rpx;
  border-bottom: rgba(203,203,203,.8) 1px solid;
}
</style>
